/*
 * CombineSourceBuilder.h
 *
 *  Created on: 22 juil. 2011
 *      Author: Pierrick Caillon <pierrick@megami.fr>
 */

#ifndef COMBINESOURCEBUILDER_H_
#define COMBINESOURCEBUILDER_H_

#include <limits.h>
#include <list>
#include <iostream>
#include <DataFile.h>
#include "Geometry.h"

class CombineSourceBuilder
{
private:
	int minZoom;
public:
	class iterator
	{
	public:
		virtual bool next() = 0;
		virtual std::istream* current() = 0;
	};
	class ListCleaner
	{
	private:
		bool ok;
		std::list<NamedBinaryTag::DataFile*> list;
	public:
		ListCleaner(std::list<NamedBinaryTag::DataFile*> list);
		~ListCleaner();
		void Cancel();
	};
	CombineSourceBuilder();
	std::list<NamedBinaryTag::DataFile*> LoadFiles(iterator &it) const;
	Rect ComputeBounds(const std::list<NamedBinaryTag::DataFile*> & dataFiles);
	char *CreateImage(const std::list<NamedBinaryTag::DataFile*> & dataFiles, const Rect bounds) const;
	NamedBinaryTag::ITag* MakeDataTag(const std::list<NamedBinaryTag::DataFile*> & dataFiles, char *image, const Rect bounds);
	Size ComputeImageSize(const Rect bounds) const;
};

#endif /* COMBINESOURCEBUILDER_H_ */
